package YYX.Smcs;


import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @ClassName: LoginGUi
 * @Auther: Drawin
 * @Date: 2021/12/26 16:34
 * @Description:
 */

public class LoginGUi extends JFrame implements ActionListener {
    public LoginGUi(){
        JFrame jFrame = new JFrame("登录");
        JLabel jLabel1 = new JLabel("  用户名");
        JLabel jLabel2 = new JLabel("  密码");
        JTextField jTextField1 = new JTextField(10);
        JTextField jTextField2 = new JTextField(10);
        JButton jButton1 = new JButton("登录");
        JButton jButton2 = new JButton("退出");
        JPanel jPanel1 = new JPanel();
        JPanel jPanel2 = new JPanel();

        jPanel1.setLayout(new GridLayout(3,2));
        jPanel2.setLayout(new GridLayout(1,2));
        jPanel1.add(jLabel1);
        jPanel1.add(jTextField1);
        jPanel1.add(jLabel2);
        jPanel1.add(jTextField2);


        jPanel2.add(jButton1);
        jPanel2.add(jButton2);
        jFrame.add(jPanel1, BorderLayout.NORTH);
        jFrame.add(jPanel2,BorderLayout.SOUTH);


        jFrame.setVisible(true);
        jFrame.setSize(350,150);
        jFrame.setLocationRelativeTo(null);//在屏幕中间显示
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//退出关闭JFrame

        jButton1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                jFrame.setVisible(false);
                new MainView();
            }
        });

        jButton2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
           System.exit(0);
            }
        });

    }

    @Override
    public void actionPerformed(ActionEvent e) {

    }
}
